<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>地址列表</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/aui-flex.css"/>
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css"/>
    <style>
        .aui-radio {
            margin-top: 13px;
        }

        .aui-radio:checked:after {
            top: 4px;
        }
    </style>
</head>
<body>
<div class="aui-content">
    <div class="kongshuju">
        <p>暂无数据</p>
    </div>
    <ul class="aui-list-view  after-no-border" id="addressList-content">
        <!--<li class="aui-list-view-cell">-->
            <!--<div class="aui-flex-middle aui-flex-row aui-pull-left"><input class="aui-radio aui-pull-left noBefore"-->
                                                                           <!--type="radio" name="demo1" checked="">-->
            <!--</div>-->
            <!--<div class="aui-flex-col">-->
                <!--<div class="aui-flex-item-6 aui-text-left aui-ellipsis-1">爱奖励</div>-->
                <!--<div class="aui-flex-item-6 aui-text-right">18718549184</div>-->
            <!--</div>-->
            <!--<div class="aui-flex-col aui-margin-t-10">-->
                <!--<div class="aui-flex-item-10 font-size-12 aui-text-left aui-ellipsis-1">广州市天河区中石化大厦位置就是这个</div>-->
                <!--<div class="aui-flex-item-2 aui-text-right"><i-->
                        <!--class="aui-iconfont aui-icon-edit aui-text-primary aui-margin-0"-->
                        <!--onclick="openToTwo('addressEdit_win')" tapmode></i></div>-->
            <!--</div>-->
        <!--</li>-->
    </ul>
</div>

<script id="addressList-template" type="text/x-dot-template">
    {{ for(var i in it){ }}

    <li class="aui-list-view-cell" data-id="{{=it[i].address_id}}" tapmode onclick="chooseAddress(this)">
        <div class="aui-flex-middle aui-flex-row aui-pull-left"><input class="aui-radio aui-pull-left noBefore"
                                                                       type="radio" name="demo1" checked="">
        </div>
        <div class="aui-flex-col">
            <div class="aui-flex-item-6 aui-text-left aui-ellipsis-1 address_name">{{=it[i].consignee}}</div>
            <div class="aui-flex-item-6 aui-text-right address_phone">{{=it[i].mobile}}</div>
        </div>
        <div class="aui-flex-col aui-margin-t-10">
            <div class="aui-flex-item-10 font-size-12 aui-text-left aui-ellipsis-1  address_address">{{=it[i].address}}</div>
            <div class="aui-flex-item-2 aui-text-right"><i
                    class="aui-iconfont aui-icon-edit aui-text-primary aui-margin-0"
                    onclick="goToEditAddress('{{=it[i].address_id}}')" tapmode></i></div>
        </div>
    </li>


    <!--<li class="aui-list-view-cell aui-img aui-col-xs-6 img100 aui-margin-b-15 aui-padded-b-10 aui-border-b aui-padded-0"-->
    <!--tapmode onclick="goToGoodInfo('{{=it[i].goods_id}}')">-->
    <!--<img class="" src="{{=it[i].goods_img}}">-->
    <!--<div class="aui-padded-0-10">-->
    <!--<p class="aui-ellipsis-2  font-black-12" style="height: 33px">{{=it[i].goods_name}}</p>-->
    <!--<p class="aui-margin-t-5">-->
    <!--<span class="aui-text-danger font-size-12 font-weight-700">{{=it[i].shop_price}}</span>-->
    <!--<span class="font-size-12 font-weight-700 aui-pull-right aui-padded-r-10">已卖：{{=it[i].sales_volume_base}}</span>-->
    <!--</p>-->
    <!--</div>-->
    <!--</li>-->
    {{}}}
</script>

</body>
<script src="../script/api.js"></script>
<script src="../script/doT.min.js"></script>
<script src="../script/common.js"></script>
<script src="../script/jquery.min.js"></script>
<script>
    var page = 1, isLock = false, type = 1, supplierId = "";
    var type = "";
    apiready = function () {
        getUserInfo();
        type = api.pageParam.type;
        api.parseTapmode();
        getAddressList();
//        getSupplierForId(supplierId);
        api.addEventListener({
            name: 'scrolltobottom'
        }, function (ret, err) {
            page++;
            if (isLock == false) {
                getAddressList();
            }
        })
        api.addEventListener({
            name: 'updateAddress'
        }, function (ret, err) {
            page = 1;
            getAddressList();
        })

    }
    function getAddressList() {
        showLoading()
        var url = "user/addresslist";
        var data = {};
        data["page"] = page;
//        alert(JSON.stringify(data))
        ajaxRequest(url, 'get', data, function (ret, err) {
//        alert(JSON.stringify(ret.data.company_name))
            var content = $api.byId('addressList-content');
            var tpl = $api.byId('addressList-template').text;
            var tempFn = doT.template(tpl);

            if (page > 1) {
                if (!$.trim(ret.data)) {
                    isLock = true;
                    return;
                }
                $api.append(content, tempFn(ret.data));
            } else {
                if (!$.trim(ret.data)) {
                    isLock = true;
                    showNoTip(ret.data);
                }
                $api.html(content, tempFn(ret.data));
            }

            hideLoading();

        });
    }
    function goToEditAddress(addressId) {
        api.openWin({
            name: "editAddress",
            url: "addressEdit_win.html",
            pageParam: {
                addressId: addressId
            }
        })
    }
    //订单过来选择地址时候
    function chooseAddress(obj) {
        if(type=="orderConfirm"){
            api.sendEvent({
                name:"updateConfirmAddress",
                extra:{
                    key:true,
                    address_name:$(obj).find(".address_name").eq(0).text(),
                    address_phone:$(obj).find(".address_phone").eq(0).text(),
                    address_address:$(obj).find(".address_address").eq(0).text(),
                    address_id:$(obj).attr("data-id")
                }
            })
            closeWin();
        }
//        alert(address_info.consignee)
    }
</script>
</html>